﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 重写01
{
    class Animal
    {
        public int ID { get; set; }
        public string Name { get; set; }

        public Animal() { }
        public Animal(int id, string name)
        {
            ID = id;
            Name = name;
        }

        /// <summary>
        /// 虚方法，子类可以重写，虚方法里面可以有实现的功能，我们可以去调用
        /// </summary>
        public virtual void Run()
        {
            Console.WriteLine("Animal is Running...");
        }
    }

    class Cat : Animal
    {
        public Cat() { }
        public Cat(int id, string name):base(id, name)
        {

        }
        /// <summary>
        /// 重写方法
        /// </summary>
        public override void Run()
        {
            Console.WriteLine("Cat is Running, 爪子有肉垫，没有声音...");
        }
        public void CatchMouse()
        {
            Console.WriteLine("猫抓老鼠....");
        }
    }
    class Dog : Animal
    {
        public Dog() { }
        public Dog(int id, string name) :base(id, name)
        {

        }
        public override void Run()
        {
            Console.WriteLine("Dog is Running, 边跑边叫...");
        }
        public void LookDoor()
        {
            Console.WriteLine("小狗会看门...");
        }
    }
}
